package com.mengniu.commerce.sync.controller;


import com.alibaba.fastjson.JSONObject;
import com.mengniu.commerce.common.core.domain.R;
import com.mengniu.commerce.common.core.web.controller.BaseController;
import com.mengniu.commerce.common.log.annotation.Log;
import com.mengniu.commerce.common.log.enums.BusinessType;
import com.mengniu.commerce.sync.api.base.MnResult;
import com.mengniu.commerce.sync.api.domain.CreateOrderModel;
import com.mengniu.commerce.sync.api.domain.ModifyOrderModel;
import com.mengniu.commerce.sync.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 订单创建controller
 *
 * @author zfw
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController extends BaseController
{
       @Autowired
    private OrderService orderService;

    @Log(title = "存量订单创建管理", businessType = BusinessType.INSERT)
    @PostMapping("/createOrder")
    public R orderInsert(@RequestBody List<CreateOrderModel> createOrderModelList, String source)
    {
        log.info("订单创建参数为:{},{}", JSONObject.toJSONString(createOrderModelList),source);
        //todo RetryDTO
        return orderService.createOrder(createOrderModelList,null);

    }

   /* @Log(title = "订单创建管理", businessType = BusinessType.INSERT)
    @PostMapping("/createOrder")
    public MnResult createOrder(@RequestBody OrderRegisterModel orderRegisterModel, String source, String userId)
    {
        log.info("订单创建管理:{},{}", JSONObject.toJSONString(orderRegisterModel),source);
        return orderService.createOrder(orderRegisterModel,source,userId);

    }*/

    @Log(title = "订单修改管理", businessType = BusinessType.INSERT)
    @PostMapping("/modifyOrder")
    public R  modifyOrder(@RequestBody List<ModifyOrderModel> modifyOrderModelList, String source)
    {
        log.info("订单修改参数为:{},{}", JSONObject.toJSONString(modifyOrderModelList),source);
        //todo RetryDTO
        return orderService.modifyOrder(modifyOrderModelList,null);

    }



}
